package ac.neec.mio.profile;

import ac.neec.mio.R;
import ac.neec.mio.ui.activity.ProfileActivity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;

public class ProfilePreferenceSetting {


	private static Context context;
	private static Resources resources;
	private static SharedPreferences sp;
	private static SharedPreferences.Editor editor;


	public static int getAge(){
		return sp.getInt(resources.getString(R.string.profile_age),
				ProfileActivity.AGE_DEFAULT_PARAMETER);
	}

	public static int getHeight(){
		return sp.getInt(resources.getString(R.string.profile_height),
				ProfileActivity.HEIGHT_DEFAULT_PARAMETER);
	}

	public static int getWeight(){
		return sp.getInt(resources.getString(R.string.profile_weight),
				ProfileActivity.WEIGHT_DEFAULT_PARAMETER);
	}

	public static int getRestingHeart(){
		return sp.getInt(resources.getString(R.string.profile_resting_heart),
				ProfileActivity.RESTING_HEATE_DEFAULT_PARAMETER);
	}

	public static void setRestingHeart(int heart){
		editor.putInt(resources.getString(R.string.profile_resting_heart),heart);
		editor.commit();
	}

	public ProfilePreferenceSetting(Context context) {
		this.context = context;
		resources = context.getResources();
		sp = context.getSharedPreferences(
				resources.getString(R.string.profile_preference_name)
								, context.MODE_PRIVATE);
		editor = sp.edit();
	}

	public void saveProfileData(int age,int height, int weight,String sex,int restingHeart) {
		editor.putInt(resources.getString(R.string.profile_age), age);
		editor.putInt(resources.getString(R.string.profile_height), height);
		editor.putInt(resources.getString(R.string.profile_weight), weight);
		editor.putString(resources.getString(R.string.profile_sex), sex);
		editor.putInt(resources.getString(R.string.profile_resting_heart),restingHeart);

		editor.commit();

	}


}
